package org.linlinjava.litemall.admin.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.linlinjava.litemall.admin.beans.annotation.LogAnno;
import org.linlinjava.litemall.admin.service.AdminLumiereReplaceableMaterialService;
import org.linlinjava.litemall.admin.vo.AdminLumiereReplaceableMaterialVO;
import org.linlinjava.litemall.core.util.ResponseUtil;
import org.linlinjava.litemall.db.domain.LumiereCustomizationFormula;
import org.linlinjava.litemall.db.domain.LumiereFormula;
import org.linlinjava.litemall.db.domain.LumiereGoodsFormulaCorrelation;
import org.linlinjava.litemall.db.domain.LumiereReplaceableMaterial;
import org.springframework.web.bind.annotation.*;

@Api(tags = "客户定制管理API")
@RestController
@RequestMapping("admin/replaceableMaterial")
@RequiredArgsConstructor
public class AdminLumiereReplaceableMaterialController {

    private final AdminLumiereReplaceableMaterialService adminLumiereReplaceableMaterialService;

    @ApiOperation("客户定制管理管理-查询客户定制化的可替换原料")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "goodsId",value = "商品id"),
            @ApiImplicitParam(name = "formulaId",value = "配方id"),
            @ApiImplicitParam(name = "specificationsId",value = "规格id")
    })
    @LogAnno
    @GetMapping("/list")
    public ResponseUtil.Response list(LumiereCustomizationFormula lumiereCustomizationFormula) {
        return adminLumiereReplaceableMaterialService.listFormulaMaterialReplaceableMaterial(lumiereCustomizationFormula);
    }

    @ApiOperation("客户定制管理管理-是否定制")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "goodsId",value = "商品id")
    })
    @LogAnno
    @GetMapping("/isCustomization")
    public ResponseUtil.Response isCustomization(LumiereGoodsFormulaCorrelation lumiereGoodsFormulaCorrelation) {
        return adminLumiereReplaceableMaterialService.isCustomization(lumiereGoodsFormulaCorrelation);
    }

    @ApiOperation("客户定制管理管理-修改是否定制")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "goodsId",value = "商品id"),
            @ApiImplicitParam(name = "isCustomization",value = "是否定制")
    })
    @LogAnno
    @PostMapping("/updateIsCustomization")
    public ResponseUtil.Response updateIsCustomization(LumiereGoodsFormulaCorrelation lumiereGoodsFormulaCorrelation) {
        return adminLumiereReplaceableMaterialService.updateIsCustomization(lumiereGoodsFormulaCorrelation);
    }

    @ApiOperation("客户定制管理管理-添加可替换原料")
    @LogAnno
    @PostMapping("/addReplaceableMaterial")
    public ResponseUtil.Response addReplaceableMaterial(@RequestBody AdminLumiereReplaceableMaterialVO lumiereReplaceableMaterialVO) {
        return adminLumiereReplaceableMaterialService.addReplaceableMaterial(lumiereReplaceableMaterialVO);
    }

    @ApiOperation("客户定制管理管理-更新可替换原料")
    @LogAnno
    @PutMapping("/updateReplaceableMaterial")
    public ResponseUtil.Response updateReplaceableMaterial(@RequestBody LumiereReplaceableMaterial lumiereReplaceableMaterial) {
        return adminLumiereReplaceableMaterialService.updateReplaceableMaterial(lumiereReplaceableMaterial);
    }

    @ApiOperation("客户定制管理管理-删除可替换原料")
    @LogAnno
    @DeleteMapping ("/deleteReplaceableMaterial")
    public ResponseUtil.Response deleteReplaceableMaterial(Integer id) {
        return adminLumiereReplaceableMaterialService.deleteReplaceableMaterial(id);
    }




}
